<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>

<%@ page import="javax.portlet.RenderRequest" %>
<%@ page import="javax.portlet.RenderResponse" %>
<%@ page import="javax.portlet.ActionResponse" %>
<%@ page import="javax.portlet.PortletPreferences" %>

<%@ page import="pl.edu.agh.portal.application.types.Message" %>
<%@ page import="pl.edu.agh.portal.application.types.Employee" %>
<%@ page import="pl.edu.agh.portal.application.utils.PortletsUtils" %>

<%@ page session="false" %>

<portlet:defineObjects/>

<% 
Message[] messageItems = (Message[])(renderRequest.getAttribute(PortletsUtils.USER_MESSAGES_KEY));
%>

<form method="post" action="<portlet:actionURL/>">
	<table width="100%">	
		<tr>
			<th width="100%" align="center" colspan ="2"><%= PortletsUtils.USER_MESSAGES_PAGE %></th>
		</tr>
		<tr>
			<td width="20%" align="center">
				<%@ include file="./include/message_menu.inc" %> </td>
			<td width="80%">
				<table width="100%"> 
					<tr>
						<th align="center"><%= PortletsUtils.NUMBER %></th>
						<th align="center"><%= PortletsUtils.MESSAGES_AUTHOR %></th>
						<th align="center"><%= PortletsUtils.MESSAGES_TITLE %></th>
						<th></th>
						<th></th>
					</tr>
					<% for (int i=0; i<messageItems.length; i++) { %>
						<tr>
							<td align="center"><%= i+1 %></td>
							<td align="center"><%= messageItems[i].getEmployee().getName() %> </td>
							<td align="center"><%= messageItems[i].getMessage() %> </td>
							<td align="center"><a href="<%= "/portal/portal/message_details.psml?" + PortletsUtils.PARAMETER_MESSAGE_ID + "=" + messageItems[i].getId() %>" ></a></td>
							<td align="center"><a href="<%= "/portal/portal/message_remove.psml?" + PortletsUtils.PARAMETER_MESSAGE_ID + "=" + messageItems[i].getId() %>" ></a></td>
						</tr>
					<% } %> 									
				</table>				
			</td>
		</tr>
	</table>
</form>


